﻿Imports MvcMusicStoreVB.Models

Namespace Controllers
    Public Class HomeController
        Inherits System.Web.Mvc.Controller

        Private storeDB As MusicStoreEntities = New MusicStoreEntities

        '
        ' GET: /Home
        Function Index() As ActionResult
            Dim albums = GetTopSellingAlbums(5)
            Return View(albums)
        End Function

        Private Function GetTopSellingAlbums(ByVal count As Integer) As List(Of Album)
            Return storeDB.Albums.
                OrderByDescending(Function(a) a.OrderDetails.Count).
                Take(count).
                ToList()
        End Function

    End Class
End Namespace